New event commands


	/cg cgName/
	
Shows an image on the screen. Image stretches to fill screen, even when game window is resized.

CG images must be loaded through Content Patcher. 

Target must begin with CG/
For example, this file:
 	{
		"Action": "Load",
        "Target": "CG/someCG123", 
        "FromFile": "assets/CGs/someCG123.png",
    },
should be shown with this command:
	/cg someCG123


	/vn cgName/
Similar to cg above. Also enables a minimal dialogue theme similar to a visual novel.


	/vn cgName fade 1.5/
	/cg cgName fade 1.5/
	
The optional fade [seconds] parameter sets the time to spend fading the next cg image in.


	/setCgFade 1.5/
Sets the default fade time for the rest of the cgs in the event, or until it's changed with this command again.

	

	/cgClear/
	
Clears the cg on the screen and removes VN theming if it's enabled.


	/var varName varValue/
	
Creates or edits a variable.
Variables can be text or numbers.
Variables get cleared on event end.
Variables can be used for:
	-if statements
	-tokenizable strings in event dialogue










	/class className(name=Nobeta,hp=100,damage=25,speed=5,greeting=Hi!)/
	/class newClass oldClass/
	/var className.varName varValue/
	
Creates or copies a class.
Anywhere you can use variables, you can use class.variables
Examples:
	/if $someClass.someVariable == 10 switchEvent 123_abc/
	/add $someClass.someVariable 10/
	/speak [var someClass.name] \"[var someClass.message]\"/
	
Any amount and type of variables work.










	/add varName 10/
	/add varName -10.55/

Adds (or removes if negative) the value from the variable's value if the variable is a number.










	/varAppend <varName> <text>/
	/varAppend speech Great, isn't it?/
	/varAppend speech #$b#I am doing great, by the way!/
	
Adds text to the end of a variable.
Useful for speech tokens. Example:
/var speech Hello, how are you?/if $doingGood == true varAppend speech #$b#I am doing great, by the way!$h/switchEvent 123_abc/
/speak Renata \"[var speech]\"/










	/sum varName ($var1,100,250,$var2,$var3,1.5)/

Creates or edits a variable, with the value being the sum of the numbers in the brackets.








	/printVar varName/

Debug only, shows the variable's value if using SMAPI's developer version.







	/if (conditions) (command)
	/if (conditions) {commands separated by ;}
	/if $varName == helloabc switchEvent 123_abc/		
	/if $varName < 100 switchEvent 123_abc/
	/if $varName == $otherVarName switchEvent 123_abc/
	/if [Season] == winter speak Renata \"It's winter!\"/
	/if $varName == 100 && $varname2 == 100 {command1;command2;command3;command4;command5;etc...}/
	/if $varName == null {commandsIfNull}
	
Checks condition(s), then executes the command(s) after.
You must prefix a variable name with $ to differentiate it from a static value.
After the if statement, almost all event commands work, but switchEvent is recommended for readability and simplicity.
You can use [Tokens].
You can check if a variable exists or doesn't with 		/if $varName == null {commands if varibale doesn't exist}/		/if $varName != null {commands if variable exists}/
You can set variables to null with		/var someVar null/

Operators:
	==
	!=
	>
	>=
	<
	<=

You can use && (and) and || (or) to create multiple conditions in one statement, example:
	/if $someVar == 100 && $anotherVar == 50 && $yetAnotherVar == 25 switchEvent 123_abc/		// "&&" means all conditions must be true.
	/if $someVar == 100 || $anotherVar == 50 || $yetAnotherVar == 25 switchEvent 123_abc/		// "||" means at least one of the conditions must be true.







	/ifChar Ashley switchEvent 123_abc/
	/ifChar !Ashley switchEvent 123_abc/
	/ifChar Ashley switchEvent {command1;command2;etc}/

Checks if a character exists, then executes the command.
Useful to check if a mod is loaded. 
Can be inverted by prefixing character name with !. 
Inversion is useful to skip part of an event if a character doesn't exist.











	/ifItem <itemId> [numberOfItems=1] (commands if true)/
	/ifItem 232 switchEvent 123_abc/
	/ifItem 232 99 switchEvent 123_abc/
	/ifItem (F)232 99 switchEvent 123_abc/
	/ifItem (F)232 99 {command1;command2;command3;etc}/
	
Checks if player has items in inventory, then executes the command. 
If item type is not specific, defaults to (O)Objects
Item types
(O) 	Objects	(Most common items)
(T)		Tools
(W) 	Weapons
(B) 	Boots
(H) 	Hats
(S) 	Shirts
(P) 	Pants
(BC) 	Big Craftables
(F) 	Furniture
(FL) 	Flooring
(WP)	Wallpaper








	/ifMod <modId> <eventCommandsIfTrue>/
	/ifMod recettearmod switchEvent 123_abc/
	/ifMod recettearmod switchEvent {command1;command2;command3;etc}/

Checks if a mod is loaded, then executes the command.
<modId> is in the mod's manifest.json.








	/ifFlag ccVault switchEvent 123_abc/
	/ifFlag ccVault switchEvent {command1;command2;command3;etc}/

Checks if a mail flag is set, then executes the command. https://stardewvalleywiki.com/Modding:Mail_data
Mail flags do not necessarily need to have a readable mail, things like ccBus are also mail flags.








	/gsq #Season == WINTER#switchEvent 123_abc/

Checks if a GameStateQuery is true, then execute the command after the #.
https://stardewvalleywiki.com/Modding:Game_state_queries








	/func 123_abc [loops=1]/
	/func 123_abc/
	/func 123_abc 15/
	
Calls a sub-event/fork like a function, continuing back where it got called when it's done.
[loops] decides how many times to repeat.














	/dynamicQuestion/
	/dynamicQuestion [QuestionText=""]/
	
	/clearDynamicQuestion/
	
	/addAnswer <answer> <fork>/
	/addAnswer <answer> <command>/
	/addAnswer <answer> {command1;command2;command3;etc}/
	/addAnswer \"Answer goes here\" 123_abc/
	/addAnswer \"Answer goes here\" speak Renata \"Yippee hooray!\"/
 	/addAnswer \"Answer goes here\" {command1;command2;command3;command4;}/

Dynamic questions are like quickQuestions, but all available answers can be determined by if statements.
For example:
/clearDynamicQuestion/addAnswer \"I am doing good.\" 123123_answer_doingGood/addAnswer \"I am doing bad.\" 123123_answer_doingBad/if $foundDiamond == true addAnswer \"I found a diamond!\" 123123_answer_foundDiamond/dynamicQuestion How are you doing?/	
	
In the above event, there's 2 answers that are always available, and a 3rd answer that is only conditionally available.	
The first variable of addAnswer is the button's text, the second variable is the fork/sub-event to switch to when that answer is chosen.
Forks are the only thing that can go after an addAnswer command.

Make sure to start a line with clearDynamicQuestion so there are no left-over answers from previous questions.

If you include a <fork> like		/addAnswer \"That's nice.\" 123_abc/		The command will be a switchEvent












	/endTeleport Forest 25 50/
	/endTeleport Forest 25 50 3/

Ends the event and teleports to the location and position.
Optional argument "3" is facing direction. 0/1/2/3 = up/right/down/left







	/switchRandomEvent/
	/switchRandomEvent [any number of forks]/
	/switchRandomEvent 123_abc1 123_abc2 123_abc3 123_abc4/
	
Switches to one of the random event forks in the list.
if [any number of forks] is included, ignores the list and chooses one from the argument.




	/addRandomEvent <fork> [weight=100]/
	/addRandomEvent 123_abc1/
	/addRandomEvent 123_abc2 50/					//This one is half as likely to happen as others.
	/ifChar Morgan addRandomEvent 123_morgan 100/

Adds a random event to the switchRandomEvent list. Useful with if statements.
[weight] determines likelyhood of event being picked relative to others. Default 100.



	/clearRandomEvent/
	
Clears the random event list.








	/setGotoEvent <forkAlias> <fork>/
	/setGotoEvent someContinueEvent 123123_abc/
	/gotoEvent <forkAlias>/
	/gotoEvent someContinueEvent/
	
Set an event to switch to later on.
Example:

"123_start":			"setGotoEvent afterEvent 123_continue1/switchEvent 123_someOtherFork",
"123_someOtherFork": 	"do/Stuff/Here/gotoEvent afterEvent",
"123_continue1":		"it goes to here",







	/viewportMoveTo <x> <y> <timeMS> [waitUntilDone=false]/
	/viewportMoveTo 37 42 2500/
	/viewportMoveTo 37 42 2500 true/

Moves viewport to tile position over time.

















Puppetry!

	/Puppet <name> <source> <x> <y> <spriteWidth> <spriteHeight> <scale> [startingFrame = 0]/
	/Puppet Sue Sue -0.5 0.75 16 32 2/
	/Puppet Sue Sue -0.5 0.75 16 32 2 13/
	/Puppet Jas Portraits\\Jas -0.5 0.75 64 64 2/
	/Puppet ChocolateCake 220 -0.5 0.75 64 64 2/
	
Creates a puppet that can be moved around and animated. Coordinates in screen-space. (-1 to 1) When resizing the screen, the puppets' positions and size will update accordingly.

<source> can be:
-A spritesheet loaded through content patcher to the "Puppets/x" path.
-Any texture in the game like 	Portraits\\Jas
-An item ID like 220 or (O)220 for a chocolate cake.

<x> and <y>, -1 is the left or top, 0 is the center, and 1 is the right or bottom.
Puppets appear in front of CGs. Newer puppets appear in front of older puppets.
Content Patcher example:

	{
          "Action": "Load",
          "Target": "Puppets/Sue",  
          "FromFile": "assets/Puppets/Sue.png",
    },
	
	
	
	
	/PuppetPosition <name> <x> <y> [time]/
	/PuppetPosition Sue 0.2 -0.7/
	/PuppetPosition Sue 1 0.2 500/

Instantly moves puppet to target position.
If optional [time] is set, move puppet to target position in specified time in milliseconds (1000 per second).	




	/PuppetRotateTo <name> <degrees> [time]/
	/PuppetRotateTo Sue 90/
	/PuppetRotateTo Sue 270 500/

Instantly rotates puppet to target angle in degrees.
If optional [time] is set, rotate puppet to target angle in specified time in milliseconds (1000 per second).	




	/PuppetFrame <name> <frame>/
	/PuppetFrame Sue 1/

Sets the puppet's frame.
The frame's graphic depends on the puppet's sprite size.	
	
	
	
	
	/PuppetDefineAnimation <animationName> <any number of frames>/					
	/PuppetDefineAnimation Dance 0 1 2 4 2 2 3 1 3 0 0 2 3 10 23 24 10/
	/PuppetDefineAnimation Laugh 12 14/

Define an animation, to be used with PuppetAnimate.
The frames' graphics depend on the puppet's sprite size. Only use horizontal animations on the spritesheet. No rows.




	/PuppetAnimate <name> <animationName> <timeBetweenFrames> <numberOfLoops> <endFrame>/		//TODO make endframe optional		
	/PuppetAnimate Sue Dance 250 5 2/
	/PuppetAnimate Sue Laugh 100 -1 0/

Animates a puppet with an animation defined by PuppetDefineAnimation.
If <numberOfLoops> is set to -1, loops indefinitely.
If <numberOfLoops> is set to 0 or 1, only does animation once.	




	/PuppetFlip <name> <flipType>
	/PuppetFlip Sue left/

Flips the puppet.
By default puppets face right.
<flipType> options are:
	right
	left
	up




	/PuppetDefinePosition <positionName> <x> <y>/
	/PuppetDefinePosition CastleCourtyard 0.2 0.5/

Defines a position to be used with PuppetPosition.
	/PuppetPosition Sue CastleCourtyard/
	/PuppetPosition Sue CastleCourtyard 500/
You could make a boardgame with this for example	/PuppetDefinePosition tile1 -0.523 -0.723/PuppetDefinePosition tile2 -0.591 -0.654/etc




	/PuppetBoil <name> [doOffset=true] [doAnimation=true] [boilAnimationOverride=null] [timeBetweenFrames=200]/
	/PuppetBoil Aubrey/
	/PuppetBoil Aubrey false/
	/PuppetBoil Aubrey true false/
	/PuppetBoil Aubrey true false AlternativeBoilAnimation/
	/PuppetBoil Aubrey true false AlternativeBoilAnimation 500/

Animates a puppet with a boiling effect. This makes the puppet jitter.
[doOffset] jitters size and position slightly.
[doAnimation] is equal to frames 0 1 2 1 looping at 200 MS/frame. You need to prodive your own art in the spritesheet at those frames.
if [boilAnimationOverride] is set, uses that defined animation instead of frames 0 1 2 1




	/PuppetFade <fadeTimeMilliseconds> <any number of puppets>
	/PuppetFadeIn <fadeTimeMilliseconds> <any number of puppets>
	/PuppetFade 500 Sue King Toroko/
	/PuppetFadeIn 2500 Sue/

Fades puppets in or out over a set duration.






	/PuppetCg <cgName> <puppetName> <x> <y> <puppetName2..> <x2..> <y2..>/
	/PuppetCg <cgName> <puppetName> <locationName> <puppetName2..> <locationName>/
	/PuppetCg castle knight 0.3 0.5 spearman 0.2 0.4/
	/PuppetCg castle knight battlements spearman courtyard/
   
Shows a cg idential to /cg/ and also instantly moves any number of puppets to the positions.
Puppets must exist before being called.




	/PuppetShow/
	/PuppetHide/
	/PuppetShow [anyNumberOfPuppets]/
	/PuppetHide [anyNumberOfPuppets]/
	/PuppetShow john1 john2 john3/
	/PuppetHide john1 john2 john3/

Hides or shows all puppets, or if [anyNumberOfPuppets] is added, the specifed puppets.








PRECONDITIONS

Preconditions are superiour to Content Patcher's "When" field because when using the "When" field, you can't access the events through the console if the conditions aren't met.

New preconditions


	/ifChar <characterName>/
	
Check if character exists.




	/ifMod <UniqueID>/
	/ifModAny <several UniqueID>/
	/ifModAll <several UniqueID>/
	
Check if mod(s) exist.
<UniqueID> can be found in a mod's manifest.json.



















TOKENS

Tokens can be used in if statements, or anywhere else really. Example:
/if [DayOfMonth] == 24 && [Season] == spring switchEvent 123_abc/
Tokens get parsed when the event's fork is switched to.
This means that event commands that change the values of tokens must be done in a fork before the token's fork comes up.
	
New tokens




	[var varName]

Replaces the token with the variable's value if variable exists, otherwise the variable name.
Do NOT prefix variable names with $ here. 
Examples:


/var zeroesInAMillion 6/switchEvent 123_abc/
/speak Renata \"Hi there, mister! I love you a million! That's a 1 with [var zeroesInAMillion] 0's!$h\"/

/var sentenceToSay Hi there, how are you doing?/switchEvent 123_abc/
/speak Renata \"[var sentenceToSay]\"/

/var cgToShow someCg_winter/switchEvent 123_abc/
/cg [var cgToShow]/

IMPORTANT: DO NOT CREATE THE VARIABLE AND USE THE TOKEN IN THE SAME FORK.
EXAMPLE NOT TO DO:

/var someVar abc/speak Renata \"Hello! [var someVar]\"/

DO NOT DO THIS. INSTEAD SWITCHEVENT AND THEN DO THE DIALOGUE
TOKENS GET PARSED WHEN THE FORK IS LOADED, NOT WHEN THE COMMAND IS CALLED SO YOU'LL GET AN ERROR BECAUSE THE VARIABLE CREATED BY A COMMAND DOESN'T EXIST YET.

Correct example:

"123_a": "var someVar Hi mister farmer!/switchEvent 123_b",
"123_b": "speak Renata \"[var someVar]\"",

You can also use /parseTokens {command1;command2;command3...}/ to parse tokens when the command is called instead of when the fork is loaded.
Use round brackets instead of square brackets in this case. (var varName) instead of [var varName]
Example:
	/var message how are you doing?/parseTokens {speak Renata \"Hello Mister Farmer, (var message)\";message \"Renata just said (var message)\"}/







	[Skill farming]
	[Skill mining]
	[Skill combat]
	[Skill foraging]
	[Skill fishing]
	[Skill]
	
Player's skill level.
[Skill] is all skill levels combined.

Example:

/if [Skill combat] >= 6 addAnswer \"(Combat 6) I am a competent fighter.\" 123_skillCheckSuccess/
/if [Skill combat] < 6 addAnswer \"([Skill combat]/6) I am totally a competent fighter!!!!\" 123_skillCheckFail/
				










	[ItemCount <itemID>]
	[ItemCount 30]
	[ItemCount (F)30]
	
Number of items in inventory.

Example:

/speak Renata \"You have [ItemCount 66] amethysts in your inventory, and [ItemCount (BC)66] ancient tables!\"/
(BC) stands for big craftables